﻿///<reference path="../../../../Scripts/jquery-1.4.1-vsdoc.js"/>
///<reference path="../utils/Utils.js"/>




function ToolsPaneController(controlId) {

    ///private properties/////////////
    var _controlId = controlId;
    var _control;
    var _container;
    var _panels = new Dictionary();
    var _activePaneId;

    this.Init = function () {
        _control = $("#" + _controlId);

        _container = $("<div>", { className: "windowFullHeight" }).appendTo(_control);
    }

    this.GetActivePane = function () {
        return _panels.Lookup(_activePaneId);
    }

    this.SetActivePanelForTab = function (tabId) {
        var panel = _panels.Lookup(tabId);
        HideAllPanels();
        _activePaneId = tabId;

        if (panel != undefined) {
            panel.Show();
        }
        else {
            AddPanel(tabId);
        }
    }

    this.RemovePanel = function (tabId) {
        var panel = _panels.Lookup(tabId);
        if (panel != undefined) {
            panel.GetContainer().remove();
            _panels.Delete(tabId);
        }
    }

    function AddPanel(tabId) {        
        var panel = new ToolsPaneBase("toolsPane_" + tabId);
        _container.append(panel.GetContainer());
        _panels.Add(tabId, panel);        
    }

    function HideAllPanels() {
        for (var i = 0; i < _panels.Keys.length; i++) {
            _panels.Lookup(_panels.Keys[i]).Hide();
        }
    }    
}